<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <?php include 'inc/head.php'; ?>
</head>

<body>
  <?php include 'inc/header.php'; ?>

  <div class="container">
    <!-- content start -->
    <div class="row">
      <form method="get" class="form show-sm-up">
        <?php echo M_input(); ?>
        <div class="col-sm-12">
          <div class="input-group">
            <input id="keyword" class="form-control" type="text" name="keyword" placeholder="请输入检索内容" />
            <button type="submit" id="search" class="btn btn-light btn-outline-secondary">检索</button>
          </div>
        </div>
      </form>
    </div>

    <div class="table-responsive">
      <table class="table table-sm table-bordered table-hover">
        <form action="<?php echo M('admin', 'member', 'batch'); ?>" method="post">
          <thead class="bg-light">
            <tr>
              <th>ID</th>
              <th>帐号</th>
              <th>邮箱</th>
              <th>手机</th>
              <th>状态</th>
              <th>操作</th>
            </tr>
          </thead>
          <tbody>
            <?php
            foreach ($list as $row) {
              echo '<tr><td><input type="checkbox" name="id[]" value="' . $row['id'] . '" /></td><td>' . $row['u_name'] . '</td><td>' . $row['u_email'] . '</td><td>' . $row['u_mobile'] . '</td><td>' . ($row['u_enable'] ? '生效' : '失效') . '</td><td><a href="' . M('admin', 'member', 'view', $row['id']) . '">详情</a> <a href="' . M('admin', 'member', 'del', $row['id']) . '" onclick="return confirm(\'确认要删除吗？\')">删除</a></td></tr>';
            }
            ?>
          </tbody>
          <tfoot>
            <tr>
              <td colspan="6">
                <div class="row">
                  <div class="col-xs-12 col-sm-6">
                    <div class="btn-group btn-group-sm">
                      <input type="button" class="btn btn-light btn-outline-secondary btn-sm" id="check_all"
                        value="全选" />
                      <input type="button" class="btn btn-light btn-outline-secondary btn-sm" id="check_none"
                        value="不选" />
                      <input type="button" class="btn btn-light btn-outline-secondary btn-sm" id="check_invert"
                        value="反选" />
                    </div>
                  </div>
                  <div class="col-xs-12 col-sm-6">
                    <div class="input-group mb-0">
                      <select id="execute_method" name="execute_method" class="form-select">
                        <option value="">请选择操作</option>
                        <option value="enable">账号生效</option>
                        <option value="unable">账号失效</option>
                      </select>

                      <input type="submit" id="execute" name="execute" class="btn btn-primary"
                        onclick="return confirm('确定要执行吗')" value="执行" />

                    </div>
                  </div>
                </div>
              </td>
            </tr>
          </tfoot>
        </form>
      </table>
    </div>
    <!-- content end -->
    <nav>
      <ul class="pagination pagination-sm justify-content-center"><?php echo $pager->show(); ?></ul>
    </nav>
  </div>

  <?php include 'inc/footer.php'; ?>

  <!-- js -->
  <script type="text/javascript">
  $(function() {
    $('#check_all').click(function() {
      $('input[name="id[]"]:checkbox').prop('checked', true);
    });
    $('#check_none').click(function() {
      $('input[name="id[]"]:checkbox').prop('checked', false);
    });
    $('#check_invert').click(function() {
      $('input[name="id[]"]:checkbox').each(function() {
        this.checked = !this.checked;
      });
    });
    //操作执行验证
    $('#execute').click(function() {
      if ($('#execute_method').val() == '') {
        alert('请选择一项要执行的操作！');
        return false;
      };
      if ($('input[name="id[]"]').val() = '') {
        alert('请至少选择一项！');
        return false;
      };
    });
    //搜索验证
    $('#search').click(function() {
      if ($('#keyword').val() == '') {
        alert('请输入要查找的关键字');
        $('#keyword').focus();
        return false;
      };
    });
  });
  </script>
</body>

</html>